home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #1 / Amiga Plus 1995 #1.iso / fish-disketten / fish_941-950 / d949 / bbbbs / bbbbs65.lha / rexx / bbsHOURLY.rexx < prev    next >
OS/2 REXX Batch file  |  1992-01-01  |  2KB  |  130 lines

  1. /*   $VER: 4.3 bbsHourly.rexx 31 Dec 1991 (31.12.91)
  2.          keeps track of minutes of use per hour
  3. copyright 1990-91 Richard Lee Stockton FREELY DISTRIBUTABLE
  4. */
  5.  
  6. thishour=0
  7. prevhour=0
  8. prevhour2=0
  9. prevhour3=0
  10.  
  11. PARSE ARG hour min hours mins hourly_dir .
  12. mins=mins+hours*60
  13.  
  14. CALL MAKEDIR(hourly_dir)
  15. IF ~EXISTS(hourly_dir'/Hour') THEN
  16.   CALL countcheck(hourly_dir'/Hour' TIME('H'))
  17. IF ~EXISTS(hourly_dir'/Start') THEN
  18.   CALL countcheck(hourly_dir'/Start' DATE('I'))
  19.  
  20. IF min>=mins THEN thishour=mins
  21. ELSE
  22.   DO
  23.     thishour=min
  24.     prevhour=mins-min
  25.     IF prevhour>60 THEN
  26.       DO
  27.         prevhour2=prevhour-60
  28.         prevhour=60
  29.         IF prevhour2>60 THEN
  30.           DO
  31.             prevhour3=prevhour2-60
  32.             prevhour2=60
  33.           END
  34.       END
  35.   END
  36. IF hour=0 THEN
  37.   DO
  38.     prev=23
  39.     prev2=22
  40.     prev3=21
  41.   END
  42. ELSE IF hour=1 THEN
  43.   DO
  44.     prev=0
  45.     prev2=23
  46.     prev3=22
  47.   END
  48. ELSE IF hour=2 THEN
  49.   DO
  50.     prev=1
  51.     prev2=0
  52.     prev3=23
  53.   END
  54. ELSE
  55.   DO
  56.     prev=hour-1
  57.     prev2=hour-2
  58.     prev3=hour-3
  59.   END
  60.  
  61. thishour=thishour+countcheck(hourly_dir'/'hour 0)
  62. CALL countcheck(hourly_dir'/'hour thishour)
  63.  
  64. IF prevhour>0 THEN
  65.   DO
  66.     prevhour=prevhour+countcheck(hourly_dir'/'prev 0)
  67.     CALL countcheck(hourly_dir'/'prev prevhour)
  68.   END
  69.  
  70. IF prevhour2>0 THEN
  71.   DO
  72.     prevhour2=prevhour2+countcheck(hourly_dir'/'prev2 0)
  73.     CALL countcheck(hourly_dir'/'prev2 prevhour2)
  74.   END
  75.  
  76. IF prevhour3>0 THEN
  77.   DO
  78.     prevhour3=prevhour3+countcheck(hourly_dir'/'prev3 0)
  79.     CALL countcheck(hourly_dir'/'prev3 prevhour3)
  80.   END
  81.  
  82. EXIT
  83.  
  84.  
  85. countcheck:
  86. PARSE ARG fname' 'cknum' '.
  87. IF ~EXISTS(fname) THEN
  88.   DO
  89.     IF ~writeopen(fname) THEN RETURN(0)
  90.     CALL WRITELN(f,cknum)
  91.     CALL CLOSE(f)
  92.     RETURN(cknum)
  93.   END
  94. IF ~readopen(fname) THEN RETURN(cknum)
  95. retval=STRIP(READLN(f))
  96. CALL CLOSE(f)
  97. IF ~DATATYPE(retval,'N') THEN retval=0
  98. IF ~DATATYPE(cknum,'N') THEN cknum=0
  99. IF retval<cknum THEN
  100.   DO
  101.     IF writeopen(fname) THEN
  102.       DO
  103.         CALL WRITELN(f,cknum)
  104.         CALL CLOSE(f)
  105.         RETURN(cknum)
  106.       END
  107.   END
  108. RETURN(retval)
  109.  
  110.  
  111. readopen:
  112. PARSE ARG fname
  113. ok=OPEN(f,fname,'R')
  114. IF ok~=0 THEN RETURN(1)
  115. line=fname 'failed to open for reading!'
  116. SAY line
  117. RETURN(0)
  118.  
  119.  
  120. writeopen:
  121. PARSE ARG fname
  122. CALL CLOSE(f)
  123. ok=OPEN(f,fname,'W')
  124. IF ok~=0 THEN RETURN(1)
  125. line=fname 'failed to open for writing!'
  126. SAY line
  127. RETURN(0)
  128.  
  129. /* bbsHourly.rexx */
  130.